package demo03;

import java.util.Scanner;

public class Test02StringNumber {
    public static void main(String[] args) {
        System.out.println("请输入字符串");
        String str = new Scanner(System.in).next();
        int[] array = StringNumber(str);
        System.out.println("字符串中大写字母有" +array[0]+"个，小写字母有"+array[1]+"个，数字有"+array[2]+"个");
    }

    public static int[] StringNumber(String str) {
        int[] array = new int[3];
        for (int i = 0; i < str.length(); i++) {
            char[] chars = str.toCharArray();
            if (chars[i] >= 'A' && chars[i] <= 'Z')
                array[0] = array[0] + 1;
            if (chars[i] >= 'a' && chars[i] <= 'z')
                array[1] = array[1] + 1;
            if (chars[i] >= '0' && chars[i] <= '9')
                array[2] = array[2] + 1;
        }
        return array;
    }
}
